#!/usr/bin/env python 

import os
import sys

if len(sys.argv) != 3:
    print >>sys.stderr, "./%s <original-directory> <mirrored-directory>" %sys.argv[0]

sys.argv[1] = os.path.relpath(sys.argv[1])
sys.argv[2] = os.path.relpath(sys.argv[2])
for curdirbasename, subdirList, filesList in os.walk(sys.argv[1]):
    for dirname in subdirList:
	if os.path.exists( os.path.join(curdirbasename.replace(sys.argv[1], sys.argv[2]), dirname) ) == False:
	    print "Directory missing from mirror: %s" %(os.path.join(curdirbasename, dirname))
    for filename in filesList:
	if os.path.exists( os.path.join(curdirbasename.replace(sys.argv[1], sys.argv[2]), filename) ) == False:
	    print "File missing from mirror: %s" %(os.path.join(curdirbasename, filename))
	elif os.path.getsize( os.path.join(curdirbasename, filename) ) != os.path.getsize( os.path.join(curdirbasename.replace(sys.argv[1], sys.argv[2]), filename) ):
	    print "File size differs in mirror and original location: %s" %(os.path.join(curdirbasename, filename))
